
<!-- setup执行时机 
    在生命周期函数eforeCreate之前执行一次，而且setUp函数没有this
    两个参数 props 接收父组件的值
    context
-->
<template>
  <h1>{{ aa }}</h1>
  <button @click="clickMe">
       点我
  </button>
</template>

<script>
import { ref  } from 'vue'
export default {
  watch: {
  },
    name:'hello world',
    props:['msg'],
    emits:['xd'],
    beforeCreate(){
      console.log('===beforCreate===')
    },
    setup(props,context){
        let aa = ref(123)
        console.log('===setup===') //先打印setUp
        console.log(this) //没有this指向
        console.log(props.msg)
        console.log(context)
        aa.value  = props.msg
        function clickMe(){
            context.emit('xd','context子组件的值')
        }
        return{
            aa,
            clickMe
        }
    },
    mounted(){
        this.$emit('xd','子组件的值')
    }
}
</script>

<style>

</style>
